jsx3.Class.defineClass(
    "ux.cdb.admin.queries.QueryStage", jsx3.lang.Object, [ux.cdb.admin.AdminStage],
    function (plugin) {
		var cmpFolder = null;
		
		
        plugin.instance = null;

        plugin.getInstance = function() {
			var queryModules = {
                'student'  : 'ux/cdb/admin/queries/student/',
                'contract' : 'ux/cdb/admin/queries/contract/',
                'loan' : 'ux/cdb/admin/queries/loan/',
                'organ' : 'ux/cdb/admin/queries/organ/',
                'agreement' : 'ux/cdb/admin/queries/agreement/',
                'excel' : 'ux/cdb/admin/queries/excel/',
                'insideOrgan' : 'ux/cdb/admin/queries/insideOrgan/'
            };

			//NOTICE: all arguments is ordinal in menu.xml.
			cmpFolder = queryModules[arguments[0]];
			if(!cmpFolder){
				alert('No module for specified query type:'+querytype);
				return;
			}
            if(!this.instance) {
                this.instance = new plugin();
            }
            return this.instance;
        }

        plugin.prototype.getTabText = function() {
            return 'Queries';
        }

        plugin.prototype.getNamespace = function() {
            return "ux.cdb.admin";
        }   

        plugin.prototype.getComponentUIPath = function() {
            return cmpFolder + "ui/query.xml";
        }

        plugin.prototype.loadComponent = function(parent) {
            ux.megatron.Main.loadUIResourceAsync(parent, this.getNamespace(), this.getComponentUIPath(), this, this.componentLoaded);
        }

        plugin.prototype.componentLoaded = function(objEvent) {
            if (objEvent.status == "SUCCESS") {
				ux.megatron.Main.loadClass("ux/cdb/admin/queries/QueryUtil.js","ux.cdb.admin");
				ux.megatron.Main.loadResource("ux/cdb/admin/queries/jss/query.xml","ux.cdb.admin","ljss_loanQuery","ljss");
                objEvent.obj._initialize();
				// TODO: put code what you want do after below.
            }
            else {
                if (objEvent.exception) {
                    ux.megatron.Main.logException(objEvent.exception, objEvent.message);
                }
                else {
                    jsx3.log(objEvent.message);
                }
            }
        }
    });